package cn.jasonone.service.impl;

import cn.jasonone.bean.Book;
import cn.jasonone.dao.BookDao;
import cn.jasonone.service.BookService;
import cn.jasonone.vo.PageInfo;

public class BookServiceImpl implements BookService {
	private BookDao dao = new BookDao();

	@Override
	public boolean addBook(Book book) {
		book.setStatus(0);
		return dao.addBook(book);
	}

	@Override
	public PageInfo<Book> findAll(int page, int pageSize, Book book) {
		// 前端未指定查询状态时,只查询有效的图书
		if (book.getStatus() == null) {
			book.setStatus(0);
		}
		page = page < 1 ? 1 : page;
		pageSize = pageSize < 1 ? 10 : pageSize;
		return dao.findAll(page, pageSize, book);
	}

	@Override
	public boolean deleteById(Integer id) {
		return dao.deleteById(id);
	}

	@Override
	public Book findById(Integer id) {
		return dao.findById(id);
	}

	@Override
	public boolean updateBook(Book book) {
		return dao.updateBook(book);
	}

}
